$(function(){ $('#lanpos').css('top',$('.on').position().top); $('.sidenavul li').hover(function(){ $('#lanpos').css('top',$(this).position().top); },function(){ $('#lanpos').css('top',$('.on').position().top); }) //$('.sidenavul li').click(function(){ // for(var i=0;i<$('.sidenavul li').size();i++){ // if(this==$('.sidenavul li').get(i)){ // $('.sidenavul li').eq(i).children('a').addclass('on'); // }else{ // $('.sidenavul li').eq(i).children('a').removeclass('on'); // } // } // }) // offset() position() var newbox = document.getelementbyid("newbox_new"); var newboxtop = 260; document.onscroll = function() { var doctop = document.body.scrolltop | document.documentelement.scrolltop; if (newboxtop < (doctop)) { var scrollheight = $(document).height(); var scrolltop = $(window).scrolltop(); var $footerheight = $('.footer').outerheight(true); var $newboxheight = $('#newbox_new').outerheight(true); var $windowheight = $(window).innerheight(); if( $newboxheight + 60 < scrollheight - scrolltop - $footerheight ){ //newbox.setattribute("style", "position:fixed; top: 10px; z-index:200;"); //newbox.style.csstext = "position:fixed; top: 10px; z-index:200;"; newbox.classname = "wakaka01"; }else{ var nowheight=$windowheight + scrolltop + $footerheight + 60 - scrollheight //newbox.setattribute("style", "position:absolute; top: auto; z-index:200; bottom:30px;"); //newbox.style.csstext = "position:absolute; top: auto; z-index:200; bottom:30px;"; newbox.classname = "wakaka02"; } } else { //newbox.setattribute("style", ""); newbox.classname = ""; } } })